<?php
/**
 * class App_Model_Place
 *
 * @author kim
 */
class App_Model_Place extends App_Model_Abstract
{
    // table name
    protected $_name = 'dine2_place';

    // review status
    const STATUS_PENDING    = 1;
    const STATUS_APPROVED   = 2;
    const STATUS_DELETED    = 3;

    /**
     * get searching result
     *
     * @todo may use Zend_Lucene or Solr http://lucene.apache.org/solr/
     */
    public function getSearchResult()
    {
        return array('1');
    }

    /**
     * get top restaurants that got highest rating
     *
     * @param int $limit
     * @return array
     */
    public function getTopRestaurants($limit = 5)
    {
        $db = $this->getTable()->getAdapter();
        $query = "SELECT `dine2_place`.* FROM `dine2_place` "
               . "WHERE `status` = " . self::STATUS_APPROVED . " ORDER BY `rating` DESC LIMIT $limit";
        $r = $db->fetchAll($query);
        return $r;
    }

}